package tgc.edu.ljc.bookmanage.security;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.springframework.data.annotation.CreatedBy;

import com.fasterxml.jackson.annotation.JsonIgnore;

import tgc.edu.ljc.bookmanage.custom.BaseEntity;

@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class SysDept extends BaseEntity{
	private String name;
	@JsonIgnore
	private SysDept parent;
	
	private List<SysDept> children=new ArrayList<>();
	
	@OneToMany(cascade=CascadeType.ALL,mappedBy="parent")
	public List<SysDept> getChildren() {
		return children;
	}
	public void setChildren(List<SysDept> children) {
		this.children = children;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@ManyToOne
	@CreatedBy
	public SysDept getParent() {
		return parent;
	}
	public void setParent(SysDept parent) {
		this.parent = parent;
	}
	
	public SysDept() {
		super();
	}
	
	public SysDept(Integer id) {
		super(id);
	}
	
	
}
